﻿using AutoMapper;
using mozhi.smarterp.Finance.Accounts;
using mozhi.smarterp.Finance.Banks;
using mozhi.smarterp.Finance.Basedatas;
using mozhi.smarterp.Finance.Files;
using mozhi.smarterp.Finance.Finances.ValueObjects;
using mozhi.smarterp.Finance.Finances;
using mozhi.smarterp.Finance.Logs;
using mozhi.smarterp.Finance.Querys;
using mozhi.smarterp.Finance.Tags;
using mozhi.smarterp.Finance.MapperConverters;
using System.Collections.Generic;
using System;
using mozhi.smarterp.Finance.Treasuries;
using mozhi.smarterp.Finance.Treasuries.Payments.Requisition;

namespace mozhi.smarterp.Finance;

public class FinanceApplicationAutoMapperProfile : Profile
{
    public FinanceApplicationAutoMapperProfile()
    {
        /* You can configure your AutoMapper mapping configuration here.
         * Alternatively, you can split your mapping configurations
         * into multiple profile classes for a better organization. */

        ////CreateMap<Account, AccountDto>()
        ////   .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        ////   .ForMember(des => des.ParentCode, opt => opt.Ignore())
        ////   .ForMember(des => des.ParentName, opt => opt.Ignore())
        ////   .ForMember(des => des.Code, opt => opt.MapFrom(src => src.Code))
        ////   .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        ////   .ForMember(des => des.AccountType, opt => opt.MapFrom(src => src.AccountType))
        ////   .ForMember(des => des.Activated, opt => opt.MapFrom(src => src.Activated))
        ////   .ForMember(des => des.ParentId, opt => opt.MapFrom(src => src.ParentId))
        ////   .ForMember(des => des.IsLeaf, opt => opt.MapFrom(src => src.IsLeaf))
        ////   .ForMember(des => des.IsForeignCurrency, opt => opt.MapFrom(src => src.IsForeignCurrencyAccounting))
        ////   .ForMember(des => des.DimensionItems, opt => opt.MapFrom(src => src.DimensionItems));

        //CreateMap<AccountDimensionItem, AccountDimensionItemDto>()
        //  .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //  .ForMember(des => des.AccountId, opt => opt.MapFrom(src => src.AccountId))
        //  .ForMember(des => des.DimensionId, opt => opt.MapFrom(src => src.DimensionId))
        //  .ForMember(des => des.IsRequire, opt => opt.MapFrom(src => src.IsRequire))
        //  .ForMember(des => des.DimensionName, opt => opt.Ignore())
        //  .ForMember(des => des.TagId, opt => opt.Ignore())
        //  .ForMember(des => des.DataSourceType, opt => opt.Ignore())
        //  .ForMember(des => des.Activated, opt => opt.MapFrom(src => src.Activated));


        //CreateMap<AccountDimension, AccountDimensionDto>()
        //     .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //     .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        //     .ForMember(des => des.Code, opt => opt.MapFrom(src => src.Code))
        //     .ForMember(des => des.DataSourceType, opt => opt.MapFrom(src => src.DataSourceType))
        //     .ForMember(des => des.TagId, opt => opt.MapFrom(src => src.TagId))
        //     .ForMember(des => des.TagName, opt => opt.MapFrom(src => ""))
        //     .ForMember(des => des.Activated, opt => opt.MapFrom(src => src.Activated));

        //CreateMap<BankType, BankTypeDto>()
        //    .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //    .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        //    .ForMember(des => des.Activated, opt => opt.MapFrom(src => src.Activated));

        //CreateMap<BankAccount, BankAccountDto>()
        //   .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //   .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        //   .ForMember(des => des.CurrencyId, opt => opt.MapFrom(src => src.CurrencyId))
        //   .ForMember(des => des.BankTypeId, opt => opt.MapFrom(src => src.BankTypeId))
        //   .ForMember(des => des.Number, opt => opt.MapFrom(src => src.Number))
        //   .ForMember(des => des.BranchInfo, opt => opt.MapFrom(src => src.BranchInfo))
        //   .ForMember(des => des.CurrencyName, opt => opt.MapFrom(src => ""))
        //   .ForMember(des => des.BankTypeName, opt => opt.MapFrom(src => ""))
        //   .ForMember(des => des.Activated, opt => opt.MapFrom(src => src.Activated));




        //CreateMap<Tag, TagDto>()
        //   .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //   .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        //   .ForMember(des => des.Code, opt => opt.MapFrom(src => src.Code))
        //   .ForMember(des => des.Activated, opt => opt.MapFrom(src => src.Activated))
        //   .ForMember(des => des.Items, opt => opt.MapFrom(src => src.Items));

        //CreateMap<TagItem, TagItemDto>()
        //   .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //   .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        //   .ForMember(des => des.Code, opt => opt.MapFrom(src => src.Code));



        //CreateMap<AccountBalance, AccountBalanceItemDto>()
        //   .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //   .ForMember(des => des.CurrencyId, opt => opt.MapFrom(src => src.CurrencyId))
        //   .ForMember(des => des.Period, opt => opt.MapFrom(src => src.Period))
        //   .ForMember(des => des.OpeningAmount, opt => opt.MapFrom(src => src.OpeningAmount))
        //   .ForMember(des => des.OpeningAmountFr, opt => opt.MapFrom(src => src.OpeningAmountFr))
        //   .ForMember(des => des.DebitAmount, opt => opt.MapFrom(src => src.DebitAmount))
        //   .ForMember(des => des.DebitAmountFr, opt => opt.MapFrom(src => src.DebitAmountFr))
        //   .ForMember(des => des.CreditAmount, opt => opt.MapFrom(src => src.CreditAmount))
        //   .ForMember(des => des.CreditAmountFr, opt => opt.MapFrom(src => src.CreditAmountFr))
        //   .ForMember(des => des.CurrentYearDebitAmount, opt => opt.MapFrom(src => src.CurrentYearDebitAmount))
        //   .ForMember(des => des.CurrentYearDebitAmountFr, opt => opt.MapFrom(src => src.CurrentYearDebitAmountFr))
        //   .ForMember(des => des.CurrentYearCreditAmount, opt => opt.MapFrom(src => src.CurrentYearCreditAmount))
        //   .ForMember(des => des.CurrentYearCreditAmountFr, opt => opt.MapFrom(src => src.CurrentYearCreditAmountFr))
        //   .ForMember(des => des.ClosingAmount, opt => opt.MapFrom(src => src.ClosingAmount))
        //   .ForMember(des => des.ClosingAmountFr, opt => opt.MapFrom(src => src.ClosingAmountFr))
        //   .ForMember(des => des.CurrencyCode, opt => opt.Ignore())
        //   .ForMember(des => des.DimensionGroupValueItems, opt => opt.Ignore());

        //CreateMap<List<AccountBalance>, AccountBalanceDto>().ConvertUsing(new AccountBalancesToDtoConverter());

        //CreateMap<DimensionGroupValueItemDto, DimensionGroupValueItemQuery>()
        //    .ForMember(des => des.DataSourceType, opt => opt.MapFrom(src => src.DataSourceType))
        //    .ForMember(des => des.TagId, opt => opt.MapFrom(src => src.TagId))
        //    .ForMember(des => des.Value, opt => opt.MapFrom(src => src.Value));

        //CreateMap<DimensionGroupValueItem, DimensionGroupValueItemDto>()
        //   .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //   .ForMember(des => des.DataSourceType, opt => opt.MapFrom(src => src.DataSourceType))
        //   .ForMember(des => des.TagId, opt => opt.MapFrom(src => src.TagId))
        //   .ForMember(des => des.Value, opt => opt.MapFrom(src => src.Value))
        //   .ForMember(des => des.Label, opt => opt.MapFrom(src => src.Label));

        //CreateMap<Settlement, SettlementDto>()
        //   .ForMember(des => des.Period, opt => opt.MapFrom(src => src.Period))
        //   .ForMember(des => des.Closed, opt => opt.MapFrom(src => src.Closed));

        //CreateMap<JournalNumberPrefix, JournalNumberPrefixDto>()
        //   .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //  .ForMember(des => des.Code, opt => opt.MapFrom(src => src.Code))
        //  .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        //  .ForMember(des => des.IsDefault, opt => opt.MapFrom(src => src.IsDefault));

        //CreateMap<Journal, JournalDto>()
        //   .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //  .ForMember(des => des.NumberPrefix, opt => opt.Ignore())
        //  .ForMember(des => des.NumberPrefixId, opt => opt.MapFrom(src => src.NumberPrefixId))
        //  .ForMember(des => des.Number, opt => opt.MapFrom(src => src.Number))
        //  .ForMember(des => des.FullNumber, opt => opt.Ignore())
        //  .ForMember(des => des.TotalAmountFr, opt => opt.MapFrom(src => src.TotalAmountFr))
        //  .ForMember(des => des.TotalAmount, opt => opt.MapFrom(src => src.TotalAmount))
        //  .ForMember(des => des.SourceType, opt => opt.MapFrom(src => src.SourceType))
        //  .ForMember(des => des.Items, opt => opt.MapFrom(src => src.Items));

        //CreateMap<JournalItem, JournalItemDto>()
        // .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        // .ForMember(des => des.Summary, opt => opt.MapFrom(src => src.Summary))
        // .ForMember(des => des.AccountId, opt => opt.MapFrom(src => src.AccountId))
        // .ForMember(des => des.AccountFullName, opt => opt.Ignore())
        // .ForMember(des => des.CurrencyId, opt => opt.MapFrom(src => src.CurrencyId))
        // .ForMember(des => des.CurrencyName, opt => opt.Ignore())
        // .ForMember(des => des.Amount, opt => opt.MapFrom(src => src.Amount))
        // .ForMember(des => des.AmountFr, opt => opt.MapFrom(src => src.AmountFr))
        // .ForMember(des => des.ExchangeRate, opt => opt.MapFrom(src => src.ExchangeRate))
        // .ForMember(des => des.DebitAmount, opt => opt.MapFrom(src => src.DebitAmount))
        // .ForMember(des => des.CreditAmount, opt => opt.MapFrom(src => src.CreditAmount))
        //.ForMember(des => des.DimensionGroupValueId, opt => opt.MapFrom(src => src.DimensionGroupValueId))
        //.ForMember(des => des.DimensionGroupValueItems, opt => opt.Ignore());

        //CreateMap<EndPeriodProcessItem, EndPeriodProcessItemDto>()
        //  .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //  .ForMember(des => des.Index, opt => opt.MapFrom(src => src.Index))
        //  .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        //  .ForMember(des => des.Settings, opt => opt.MapFrom(src => src.Settings));

        //CreateMap<EndPeriodProcessItemSetting, EndPeriodProcessItemSettingDto>()
        // .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        // .ForMember(des => des.Index, opt => opt.MapFrom(src => src.Index))
        // .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        // .ForMember(des => des.DefaultAccountCode, opt => opt.MapFrom(src => src.DefaultAccountCode))
        // .ForMember(des => des.CustomAccountCode, opt => opt.MapFrom(src => src.CustomAccountCode))
        // .ForMember(des => des.CustomAccountName, opt => opt.Ignore())
        // .ForMember(des => des.CustomAccountId, opt => opt.Ignore());

        //CreateMap<TrialBalanceResult, TrialBalanceResultDto>()
        //  .ForMember(des => des.Passed, opt => opt.MapFrom(src => src.Passed))
        //  .ForMember(des => des.DebitOpeningAmount, opt => opt.MapFrom(src => src.DebitOpeningAmount))
        //  .ForMember(des => des.CreditOpeningAmount, opt => opt.MapFrom(src => src.CreditOpeningAmount))
        //  .ForMember(des => des.CurrentYearDebitAmount, opt => opt.MapFrom(src => src.CurrentYearDebitAmount))
        //  .ForMember(des => des.CurrentYearCreditAmount, opt => opt.MapFrom(src => src.CurrentYearCreditAmount));

        //CreateMap<OperationLog, OperationLogDto>()
        //  .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //  .ForMember(des => des.OperatorId, opt => opt.MapFrom(src => src.OperatorId))
        //  .ForMember(des => des.OperatorName, opt => opt.MapFrom(src => src.OperatorName))
        //  .ForMember(des => des.OperationType, opt => opt.MapFrom(src => src.Type))
        //  .ForMember(des => des.ModuleCode, opt => opt.MapFrom(src => src.ModuleCode))
        //  .ForMember(des => des.ModuleName, opt => opt.MapFrom(src => src.ModuleName))
        //  .ForMember(des => des.ObjectId, opt => opt.MapFrom(src => (Guid?)src.ObjectId))
        //  .ForMember(des => des.ObjectName, opt => opt.MapFrom(src => src.ObjectName))
        //  .ForMember(des => des.Items, opt => opt.MapFrom(src => src.Items))
        //  .ForMember(des => des.Date, opt => opt.MapFrom(src => src.CreationTime))
        //  ;

        //CreateMap<OperationLogItem, OperationLogItemDto>()
        //  .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //  .ForMember(des => des.OperationLogId, opt => opt.MapFrom(src => src.OperationLogId))
        //  .ForMember(des => des.FieldName, opt => opt.MapFrom(src => src.FieldName))
        //  .ForMember(des => des.FieldCaption, opt => opt.MapFrom(src => src.FieldCaption))
        //  .ForMember(des => des.FieldOldValue, opt => opt.MapFrom(src => src.FieldOldValue))
        //  .ForMember(des => des.FieldOldCaptionValue, opt => opt.MapFrom(src => src.FieldOldCaptionValue))
        //  .ForMember(des => des.FieldNewValue, opt => opt.MapFrom(src => src.FieldNewValue))
        //  .ForMember(des => des.FieldNewCaptionValue, opt => opt.MapFrom(src => src.FieldNewCaptionValue))
        //  .ForMember(des => des.Comment, opt => opt.MapFrom(src => src.Comment))
        //  ;

        //CreateMap<File, FileDto>()
        //  .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        //  .ForMember(des => des.FileName, opt => opt.MapFrom(src => src.FileName))
        //  .ForMember(des => des.FileSize, opt => opt.MapFrom(src => src.FileSize))
        //  .ForMember(des => des.FileExtension, opt => opt.MapFrom(src => src.FileExtension))
        //  .ForMember(des => des.ContentType, opt => opt.MapFrom(src => src.ContentType))
        //  ;

        //CreateMap<Attachment, AttachmentDto>()
        // .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        // .ForMember(des => des.FileName, opt => opt.MapFrom(src => src.FileName))
        // .ForMember(des => des.RemoteFileId, opt => opt.MapFrom(src => src.RemoteFileId))
        // .ForMember(des => des.FileExtension, opt => opt.MapFrom(src => src.FileExtension))
        // .ForMember(des => des.OwnerId, opt => opt.MapFrom(src => src.OwnerId))
        // .ForMember(des => des.ContentType, opt => opt.MapFrom(src => src.ContentType))
        // .ForMember(des => des.CreationTime, opt => opt.MapFrom(src => src.CreationTime))
        // ;

        //CreateMap<PrintTemplate, PrintTemplateDto>()
        //  .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        // .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        // .ForMember(des => des.ModuleCode, opt => opt.MapFrom(src => src.ModuleCode))
        // .ForMember(des => des.TemplateFileId, opt => opt.MapFrom(src => src.TemplateFileId))
        // .ForMember(des => des.TemplateFileName, opt => opt.Ignore())
        // .ForMember(des => des.TemplateFileContentType, opt => opt.Ignore())
        // .ForMember(des => des.ImageFileId, opt => opt.MapFrom(src => src.ImageFileId))
        // .ForMember(des => des.ImageFileName, opt => opt.Ignore())
        // .ForMember(des => des.ImageFileContentType, opt => opt.Ignore());

        //CreateMap<EndPeriodProcessResult, EndPeriodProcessResultDto>()
        // .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        // .ForMember(des => des.ItemId, opt => opt.MapFrom(src => src.ItemId))
        // .ForMember(des => des.ItemName, opt => opt.Ignore())
        // .ForMember(des => des.Period, opt => opt.MapFrom(src => src.Period))
        // .ForMember(des => des.JournalId, opt => opt.MapFrom(src => src.JournalId))
        // .ForMember(des => des.JournalNumber, opt => opt.Ignore())
        // .ForMember(des => des.JournalApproved, opt => opt.Ignore())
        // .ForMember(des => des.NeedProcess, opt => opt.MapFrom(src => src.NeedProcess))
        // .ForMember(des => des.NeedEdit, opt => opt.MapFrom(src => src.NeedEdit))
        // .ForMember(des => des.Type, opt => opt.MapFrom(src => src.Type))
        // .ForMember(des => des.MeasureValue, opt => opt.MapFrom(src => src.MeasureValue))
        // .ForMember(des => des.Items, opt => opt.MapFrom(src => src.Items));

        //CreateMap<EndPeriodProcessResultItem, EndPeriodProcessResultItemDto>()
        // .ForMember(des => des.Id, opt => opt.MapFrom(src => src.Id))
        // .ForMember(des => des.Name, opt => opt.MapFrom(src => src.Name))
        // .ForMember(des => des.Value, opt => opt.MapFrom(src => src.Value))
        // .ForMember(des => des.ValueType, opt => opt.MapFrom(src => src.ValueType))
        // .ForMember(des => des.Index, opt => opt.MapFrom(src => src.Index))
        // .ForMember(des => des.NeedEdit, opt => opt.MapFrom(src => src.NeedEdit))
        // .ForMember(des => des.ResultId, opt => opt.MapFrom(src => src.EndPeriodProcessResultId));

        CreateMap<PaymentRequisition, PaymentRequisitionDto>()
            .ForMember(des => des.Links, opt => opt.Ignore())
            .ForMember(des => des.Items, opt => opt.MapFrom(src => src.Items));

        CreateMap<PaymentRequisitionItem, PaymentRequisitionItemDto>()
           .ForMember(des => des.RequisitionAmount, opt => opt.MapFrom(src => src.Amount))
           .ForMember(des => des.RequisitionAmountFr, opt => opt.MapFrom(src => src.AmountFr))
           .ForMember(des=>des.SourceDocumentNumber,opt=>opt.Ignore());
    }
}
